#pragma once

struct DeviceInfo;

struct ChannelInfo
{
	int     TrainID;
	int     ChannelID;
	char	ChannelName[128];
	char    ChannelGBId[32];
	char	TrainGbId[32];
	DeviceInfo *GBDeviceInfo;

	ChannelInfo()
	{
		TrainID = 0;
		ChannelID = -1;
		memset(ChannelName, 0, sizeof ChannelName);
		memset(ChannelGBId, 0, sizeof ChannelGBId);
		memset(TrainGbId, 0, sizeof TrainGbId);
	}
};

struct TrainInfo
{
    int     TrainID;
	int		ServiceId;
    char	TrainName[128];
	char	TrainIp1[32];
	char	TrainIp2[32];
	char	TrainGBId[32];
	DeviceInfo *GBDeviceInfo;
	vector<ChannelInfo> Channels;

	TrainInfo()
	{
		TrainID = 0;
		ServiceId = 0;
		memset(TrainName, 0, sizeof TrainName);
		memset(TrainIp1, 0, sizeof TrainIp1);
		memset(TrainIp2, 0, sizeof TrainIp2);
		memset(TrainGBId, 0, sizeof TrainGBId);
	}
};

class CTableTrain
{
public:
    CTableTrain();
    ~CTableTrain(void);
public:
    void GetTrains(vector<TrainInfo> &vecTrains);
    void GetDevices(int iTrainID, vector<ChannelInfo> &vecDevice);
    BOOL Open();
    void Close();
private:
    char *m_strConn;
    _ConnectionPtr m_pConnection;
};

